from django.db import models
from django.contrib.auth.models import User

class Author(models.Model):
    user = models.ForeignKey(User)
    birthday = models.DateField(null=True, blank=True)
    identity_card = models.CharField(max_length=12, null=True, blank=True)
    
    
class Publisher(models.Model):
    user = models.ForeignKey(User)
    name_publisher = models.CharField(max_length=50, null=True, blank=True)
    is_exist = models.BooleanField(default=False)
    
        
class Book(models.Model):
    title = models.CharField(max_length=50, null=True, blank=True)
    category = models.CharField(max_length=30, null=True, blank=True)
    author = models.ForeignKey(Author)
    publisher = models.ForeignKey(Publisher)
    summary = models.CharField(max_length=300, null=True, blank=True)
    cited = models.CharField(max_length=150, null=True, blank=True)
    image = models.ImageField(upload_to='upload/', null=True, blank=True)
    price = models.IntegerField(null=True, blank=True)
    date_published = models.DateTimeField(auto_now=False, null=True, blank=True)
    quantity = models.IntegerField(null=True, blank=True)
    rated = models.IntegerField(null=True, blank=True)
    
    
class Customer(models.Model):
    user = models.ForeignKey(User)
    identiy_card = models.CharField(max_length=12, null=True, blank=True)
    birthday = models.DateField(null=True, blank=True)
    
class Comment(models.Model):
    user = models.ForeignKey(User)
    content = models.CharField(max_length=300, null=True, blank=True)
    book = models.ForeignKey(Book)
